﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using LunwenYun.Infrastructure.Entities.Repository;

namespace LunwenYun.Infrastructure.Entities.Entity
{
    public class Organization : IAccessible<T_Organization, Organization>, ILogicEntity<T_Organization, Organization>
    {
        public int Id { get; set; }
        public string IndustryCode { get; set; }
        public string IndustryName { get; set; }
        public string OrganizationName { get; set; }

        protected override void Covariant(T_Organization model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.IndustryName = model.IndustryName;
                this.OrganizationName = model.Organization;
                this.IndustryCode = model.IndustryCode;
            }
        }

        protected override T_Organization Inverter(Organization model)
        {
            if (model != null)
            {
                return new T_Organization()
                {
                    Id = model.Id,
                    IndustryName = model.IndustryName,
                    Organization = model.OrganizationName,
                    IndustryCode=model.IndustryCode
                };
            }
            return null;
        }

        public Organization Set(T_Organization dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
